package by.kniazhych.core.controllers.actions {
	
	/**
	 * ...
	 * @author Boutylin Mikhail
	 */
	
		import by.kniazhych.core.controllers.AbstractServerAction;
	import by.kniazhych.core.controllers.GameController;
	import by.kniazhych.core.events.GameEvent;
	import by.kniazhych.core.events.PeaceSelectionEvent;
	import by.kniazhych.core.server.common.ClientCommands;
	import by.vaukalak.core.commands.Command;
	

	
	public class DisplayPeaceChoise extends AbstractServerAction{
		
		public function DisplayPeaceChoise(target:GameController, missingPeaces:Array) {
			super(target);
			_gameContainer.showSelector(missingPeaces);
			_gameContainer.addEventListener(PeaceSelectionEvent.PEACE_SELECTED, _onPeaceSelected);
		}
		
		private function _onPeaceSelected(e:PeaceSelectionEvent):void {
			_gameContainer.hideSelector();
			dispatchEvent(new GameEvent(GameEvent.ACTION_PROCESSED));
			_target.dispatchCommand(new Command(ClientCommands.SELECT_PEACE, [e.peaceType]));
		}
		
	}

}